package model.siw{
	
	import mx.collections.ArrayList;
	
	/*
	  Singleton mode
	 * */
	public class SIW{	
		
		private var _id:String;
		
		private var _name:String;
		
		private var _rules:ArrayList;
		
		private var _trs:ArrayList;
		
		private var _crs:ArrayList;
		
		private static var siw:SIW;
		
		public function SIW(){
			_rules=new ArrayList();
			_trs=new ArrayList();
			_crs=new ArrayList();
		}
		
		public static function createInstance():SIW{
			if(siw==null){
				siw=new SIW();
			}
			
			return siw;
		}
		
		public function genXML():String{
			var xml:String="";
			var i:int;
			xml+="<SIW id=\""+_id+"\" name=\""+_name+"\">\n";
			
			xml+="<rules>\n";
			for(i=0;i<_rules.length;i++){
				xml+=Rule(_rules.getItemAt(i)).genXML();
			}
			xml+="</rules>\n";
			
			xml+="<trs>\n";
			for(i=0;i<_trs.length;i++){
				xml+=TR(_trs.getItemAt(i)).genXML();
			}
			xml+="</trs>\n";
			
			xml+="<crs>\n";
			for(i=0;i<_crs.length;i++){
				xml+=CR(_crs.getItemAt(i)).genXML();
			}
			xml+="</crs>\n";
			
			xml+="</SIW>\n";
			
			return xml;
		}
		
		public function get id():String{
			return this._id;
		}
		
		public function set id(v:String){
			this._id=v;
		}
		
		public function get name():String{
			return this._name;
		}
		
		public function set name(v:String){
			this._name=v;
		}
		
		public function get rules():ArrayList{
			return this._rules;
		}
		
		public function set rules(v:ArrayList){
			this._rules=v;
		}
		
		public function get trs():ArrayList{
			return this._trs;
		}
		
		public function set trs(v:ArrayList){
			this._trs=v;
		}
		
		public function get crs():ArrayList{
			return this._crs;
		}
		
		public function set crs(v:ArrayList){
			this._crs=v;
		}

	}
}